package com.eunion.core.common.jpa.deletgate;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Set;

import org.springframework.data.repository.core.CrudMethods;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.util.Assert;

public class ProjectionRepositoryMetadata implements RepositoryMetadata {

    private final RepositoryMetadata delegate;

    private Class<?> beanClass;

    // TODO add @Overried in spring boot 2.0
    public boolean isReactiveRepository() {
        return false;
    }

    public ProjectionRepositoryMetadata(RepositoryMetadata delegate) {
        Assert.notNull(delegate, "Delegated object must not be null!");
        this.delegate = delegate;
    }

    public Class<?> getBeanClass() {
        return beanClass;
    }

    public void setBeanClass(Class<?> beanClass) {
        this.beanClass = beanClass;
    }

    public Class<? extends Serializable> getIdType() {
        return delegate.getIdType();
    }

    public Class<?> getDomainType() {
        return delegate.getDomainType();
    }

    public Class<?> getRepositoryInterface() {
        return delegate.getRepositoryInterface();
    }

    public Class<?> getReturnedDomainClass(Method method) {
        return delegate.getReturnedDomainClass(method);
    }

    public CrudMethods getCrudMethods() {
        return delegate.getCrudMethods();
    }

    public boolean isPagingRepository() {
        return delegate.isPagingRepository();
    }

    public Set<Class<?>> getAlternativeDomainTypes() {
        return delegate.getAlternativeDomainTypes();
    }


}
